﻿<nav class="flex mb-4">
    <ol class="inline-flex items-center space-x-1 text-sm font-medium md:space-x-2">
        @for (var i = 0; i < BreadcrumbItems.Count; i++)
        {
            var item = BreadcrumbItems[i];
            var isFirst = i == 0;

            @if (item.Url is not null)
            {
                <li class="inline-flex items-center">
                    @if (!isFirst)
                    {
                        <svg class="w-6 h-6 text-gray-400 dark:text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg>
                    }
                    <a href="@item.Url" class="inline-flex items-center text-gray-700 hover:text-primary-600 dark:text-gray-300 dark:hover:text-primary-500">
                        @if (isFirst && item.ShowHomeIcon)
                        {
                            <svg class="w-5 h-5 mr-2.5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"></path></svg>
                        }
                        @item.DisplayName
                    </a>
                </li>
            }
            else
            {
                <li class="inline-flex items-center">
                    @if (!isFirst)
                    {
                        <svg class="w-6 h-6 text-gray-400 dark:text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg>
                    }
                    <span class="text-gray-400 dark:text-gray-400">
                        @if (isFirst && item.ShowHomeIcon)
                        {
                            <svg class="w-5 h-5 mr-2.5 inline" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z"></path></svg>
                        }
                        @item.DisplayName
                    </span>
                </li>
            }
        }
    </ol>
</nav>

@code {
    /// <summary>
    /// Gets or sets the list of breadcrumb items.
    /// </summary>
    [Parameter]
    public List<BreadcrumbItem> BreadcrumbItems { get; set; } = new();
}
